Imports System.Xml.Serialization
Namespace CSDL

    Public Class Schema
        Inherits XEntityModelElementBase

        ''' <summary>Initializes an instance of the <see cref="Schema" /> class.
        ''' This is the default constructor for this class.</summary>
        Public Sub New()
            MyBase.New("Schema", EdmXmlNamespace)
        End Sub

        ''' <summary>Initializes an instance of the <see cref="Schema" /> class.</summary>
        ''' <param name="other">An <see cref="System.Xml.Linq.XElement"/> object to copy from.</param>
        Public Sub New(ByVal other As XElement)
            MyBase.New(other)
        End Sub

        Private __using As UsingCollection
        Private __association As AssociationCollection
        Private __complexType As ComplexTypeCollection
        Private __entityType As EntityTypeCollection

        <AutoLoad()> _
        <XmlElement("Using", GetType([Using]))> _
        Public ReadOnly Property UsingSchemas() As UsingCollection
            Get
                If (__using Is Nothing) Then
                    __using = New EdmxEditor.CSDL.UsingCollection(Me, MyBase.Name.Namespace, "Using")
                End If
                Return __using
            End Get
        End Property

        <AutoLoad()> _
        <XmlElement("Association", GetType(Association))> _
        Public ReadOnly Property Associations() As AssociationCollection
            Get
                If (__association Is Nothing) Then
                    __association = New EdmxEditor.AssociationCollection(Me, MyBase.Name.Namespace, "Association")
                End If
                Return __association
            End Get
        End Property

        <AutoLoad()> _
        <XmlElement("ComplexType", GetType(ComplexType))> _
        Public ReadOnly Property ComplexTypes() As ComplexTypeCollection
            Get
                If (__complexType Is Nothing) Then
                    __complexType = New EdmxEditor.CSDL.ComplexTypeCollection(Me, MyBase.Name.Namespace, "ComplexType")
                End If
                Return __complexType
            End Get
        End Property

        <AutoLoad()> _
        <XmlElement("EntityType", GetType(EntityType))> _
        Public ReadOnly Property EntityTypes() As EntityTypeCollection
            Get
                If (__entityType Is Nothing) Then
                    __entityType = New EdmxEditor.CSDL.EntityTypeCollection(Me, MyBase.Name.Namespace, "EntityType")
                End If
                Return __entityType
            End Get
        End Property

        <AutoLoad()> _
        <XmlElement("EntityContainer")> _
        Public Property EntityContainer() As EntityContainer
            Get
                Return DirectCast(Me.Element(MyBase.Name.Namespace + "EntityContainer"), EdmxEditor.CSDL.EntityContainer)
            End Get
            Set(ByVal value As EntityContainer)
                If (DirectCast(value, XElement).Name <> (MyBase.Name.Namespace + "EntityContainer")) Then
                    Throw New ArgumentException("Invalid Element")
                End If
                If (Me.EntityContainer IsNot Nothing) Then
                    Me.EntityContainer.Remove()
                End If
                Me.Add(New EdmxEditor.CSDL.EntityContainer(value))
            End Set
        End Property

        <XmlAttribute()> _
        Public Property [Namespace]() As String
            Get
                Return Me.@Namespace
            End Get
            Set(ByVal value As String)
                Me.@Namespace = value
            End Set
        End Property

        <XmlAttribute()> _
        Public Property [Alias]() As String
            Get
                Return Me.@Alias
            End Get
            Set(ByVal value As String)
                Me.@Alias = value
            End Set
        End Property

    End Class

End Namespace